<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <title>springcloud之sleuth微服务链路跟踪 | rongshen</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  
  
  
<link rel="stylesheet" href="/css/style.css">

  
    
<link rel="stylesheet" href="/css/highlight.css">

  
  <meta name="description" content="springcloud学习笔记，第十一章，sleuth微服务链路跟踪。">
<meta property="og:type" content="article">
<meta property="og:title" content="springcloud之sleuth微服务链路跟踪">
<meta property="og:url" content="http://example.com/2020/10/01/springcloud%E4%B9%8Bsleuth%E5%BE%AE%E6%9C%8D%E5%8A%A1%E9%93%BE%E8%B7%AF%E8%B7%9F%E8%B8%AA/index.html">
<meta property="og:site_name" content="rongshen">
<meta property="og:description" content="springcloud学习笔记，第十一章，sleuth微服务链路跟踪。">
<meta property="og:locale" content="en_US">
<meta property="og:image" content="http://cdn.rongshen2020.com/2020101b1.png">
<meta property="og:image" content="http://cdn.rongshen2020.com/2020101b2.png">
<meta property="og:image" content="http://cdn.rongshen2020.com/2020101b3.png">
<meta property="og:image" content="http://cdn.rongshen2020.com/2020101b4.png">
<meta property="article:published_time" content="2020-10-01T15:56:19.000Z">
<meta property="article:modified_time" content="2021-05-07T06:49:10.895Z">
<meta property="article:author" content="John Doe">
<meta property="article:tag" content="springCloud">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://cdn.rongshen2020.com/2020101b1.png"><meta name="generator" content="Hexo 6.1.0"></head>

<body>
  <div id="wrapper">
    <header id="header">
  <h1 id="title">
    <a href="/">rongshen</a>
  </h1>
  <nav>
    
    
      
      <a class="nav-link" href="/">Home</a>
    
      
        <span class="nav-spacer">×</span>
      
      <a class="nav-link" href="/archives">Archives</a>
    
      
        <span class="nav-spacer">×</span>
      
      <a class="nav-link" target="_blank" rel="noopener" href="https://github.com/Aaron-boom">Github</a>
    
      
        <span class="nav-spacer">×</span>
      
      <a class="nav-link" href="/2020/04/13/About-Me/">About</a>
    
    
  </nav>
</header>

    <div id="content">
      <article id="post-springcloud之sleuth微服务链路跟踪" class="article article-type-post" itemprop="blogPost" itemscope>
  <div class="article-inner">
    
      <header class="article-header">
        
  
    <h2 class="article-title" itemprop="headline name">
      springcloud之sleuth微服务链路跟踪
    </h2>
  


        <div class="article-meta">
          <time class="article-date" datetime="2020-10-01T15:56:19.000Z" itemprop="datePublished">2020-10-01</time>

          
        </div>
      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
      
        <blockquote>
<p>springcloud学习笔记，第十一章，sleuth微服务链路跟踪。</p>
</blockquote>
<span id="more"></span>

<p>sleuth:侦探。</p>
<h2 id="简介："><a href="#简介：" class="headerlink" title="简介："></a>简介：</h2><p>在微服务框架中，一个由客户端发起的请求在后端系统中会经过多个不同的服务节点调用来协同产生最后的请求结果，每一个前端请求都会形成一条复杂的分布式服务调用链路，链路中的任何一环出现高延时或错误都会引起整个请求的最后失败。</p>
<p>springcloud sleuth提供了一套完整的服务跟踪解决方案，在分布式系统中提供追踪解决方案并且兼容支持zipkin。</p>
<h2 id="搭建链路监控步骤："><a href="#搭建链路监控步骤：" class="headerlink" title="搭建链路监控步骤："></a>搭建链路监控步骤：</h2><h3 id="安装zipkin："><a href="#安装zipkin：" class="headerlink" title="安装zipkin："></a>安装zipkin：</h3><p>springcloud从F版起已经不需要自己构建Zipkin server了，只需要调用jar包即可。</p>
<p>下载地址：<code>https://zipkin.io/pages/quickstart.html</code></p>
<p>运行下载的jar包：<code>java -jar zipkin-server-2.21.7-exec.jar</code></p>
<p>监控端口是：9411</p>
<p><img src="http://cdn.rongshen2020.com/2020101b1.png"></p>
<p><img src="http://cdn.rongshen2020.com/2020101b2.png"></p>
<h3 id="使用sleuth："><a href="#使用sleuth：" class="headerlink" title="使用sleuth："></a>使用sleuth：</h3><p><img src="http://cdn.rongshen2020.com/2020101b3.png"></p>
<p>可以将之前的服务提供者8001和order80即可测试下。</p>
<ol>
<li><p>引入POM：</p>
<p>这个包虽然叫zipkin但是,里面包含了zpikin与sleuth。</p>
<pre><code class="java">&lt;!--包含了sleuth+zipkin--&gt;
&lt;dependency&gt;
    &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
    &lt;artifactId&gt;spring-cloud-starter-zipkin&lt;/artifactId&gt;
&lt;/dependency&gt;
</code></pre>
</li>
<li><p>修改配置文件：</p>
<p><img src="http://cdn.rongshen2020.com/2020101b4.png"></p>
</li>
<li><p>修改80：</p>
<p>添加pom。与上面是一样的</p>
<p>添加配置。与上面也是一样的</p>
</li>
<li><p>测试：</p>
<p>启动7001，8001,80,9411。访问：<code>http://localhost;9411</code></p>
</li>
</ol>

      
    </div>
    
    
    <div class="article-category">
      
        <b>Categories:</b>
        <a class="article-category-link" href="/categories/spring-cloud/">spring cloud</a>
      
      
        <br/>
      
      
        <b>Tags:</b>
        <a class="article-tag-none-link" href="/tags/springCloud/" rel="tag">springCloud</a>
      
    </div>
    
    
  </div>
</article>

  
<nav id="article-nav" class="article-nav">
  
    <a href="/2020/10/02/springcloud-alibaba/" id="article-nav-newer" class="article-nav-link-wrap newer">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          springcloud alibaba
        
      </div>
    </a>
  
  
    <a href="/2020/10/01/springcloud%E4%B9%8Bstream%E6%B6%88%E6%81%AF%E9%A9%B1%E5%8A%A8/" id="article-nav-older" class="article-nav-link-wrap older">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">
        
          springcloud之stream消息驱动
        
      </div>
    </a>
  
</nav>






    </div>
  </div>
  




<div id="settings-container">
  <div id="dark-mode">dark</div>
  <div id="sans-font">sans</div>
</div>
<script type="text/javascript">
let d=document,r=d.documentElement.style,f=r.setProperty.bind(r),l=localStorage,s=l.getItem('s')||(window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches),n=l.getItem('n'),m=d.getElementById("dark-mode"),b=()=>{f('--bg-color','#fafafa');f('--code-bg-color','#f4f4f4');f('--text-color','#212121');f('--secondary-color','#808080');f('--tertiary-color','#b0b0b0');f('--link-color','#b5c8cf');f('--link-hover-color','#618794');f('--link-bg-color','#dae4e7');f('--selection-color','#dae4e7');m.innerHTML="dark"},c=()=>{f('--bg-color','#212121');f('--code-bg-color','#292929');f('--text-color','#fff');f('--secondary-color','#c0c0c0');f('--tertiary-color','#6e6e6e');f('--link-color','#4d6b75');f('--link-hover-color','#96b1bb');f('--link-bg-color','#5d828e');f('--selection-color','#acc1c9');m.innerHTML="light"},o=d.getElementById("sans-font"),e=()=>{f('--body-stack','"Lora", "Georgia", "Times New Roman", serif');o.innerHTML="sans"},g=()=>{f('--body-stack','"Lato", "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", "Verdana", sans-serif');o.innerHTML="serif"};m.onclick=()=>{if(s==2){s=1;l.setItem('s',s);c()}else{s=2;l.setItem('s',s);b()}};o.onclick=()=>{if(n==2){n=1;l.setItem('n',n);g()}else{n=2;l.setItem('n',n);e()}};if(!s){s=2;l.setItem('s',2)};if(s==1){c()};if(!n){n=2;l.setItem('n',2)};if(n==1){g()};
</script>




</body>
</html>
